﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Text;
using System.IO;
using System.Xml;
using System.Data;
using Gift.WebApp;
using Gift.DAL;
using Gift.Model;

public partial class cn_member_center_my_order : BasePage
{
    // Fields
    readonly DALGoodsEntitysSpecifications theGoodsEntitysSpecifications = new DALGoodsEntitysSpecifications();
    readonly DALOrderGoodsEntitys theOrderGoodsEntitys = new DALOrderGoodsEntitys();
    readonly DALOrder theOrder = new DALOrder();
    protected string orderNo = "";

    // Methods
    protected StringBuilder GetUserOrder()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.LoginUserMember == null)
            {
                return builder;
            }
            if (base.Request.QueryString["orderNo"] != null)
            {
                this.orderNo = base.Request.QueryString["orderNo"];
            }
            DataTable orderByOrderUserAndOrderNo = this.theOrder.GetOrderByOrderUserAndOrderNo(long.Parse(base.LoginUserMember.MemberId), this.orderNo);
            if (orderByOrderUserAndOrderNo.Rows.Count > 0)
            {
                foreach (DataRow row in orderByOrderUserAndOrderNo.Rows)
                {
                    builder.AppendLine("<tr>");
                    builder.AppendLine(string.Concat(new object[] { "<td style=\"height: 32px\"><a href=\"order_info.html?orderNo=", row["orderNo"], "\">", row["orderNo"], "</a></td>" }));
                    DataTable orderGoodsEntitysByOrderNo = this.theOrderGoodsEntitys.GetOrderGoodsEntitysByOrderNo(row["orderNo"].ToString());
                    string str = "";
                    for (int i = 0; i < orderGoodsEntitysByOrderNo.Rows.Count; i++)
                    {
                        str = str + ((i == 0) ? "" : "<br />") + orderGoodsEntitysByOrderNo.Rows[i]["goodsName"].ToString();
                        DataTable table3 = this.theGoodsEntitysSpecifications.FrontDeskGetGoodsEntitysSpecificationsByGoodsEntitys(Convert.ToInt32(orderGoodsEntitysByOrderNo.Rows[i]["goodsEntitys"]));
                        if (table3.Rows.Count > 0)
                        {
                            str = str + " [";
                        }
                        for (int j = 0; j < table3.Rows.Count; j++)
                        {
                            object obj2 = str;
                            str = string.Concat(new object[] { obj2, (j > 0) ? "&nbsp;&nbsp;" : "", table3.Rows[j]["specificationsName"], "：", table3.Rows[j]["specificationsValueName"] });
                        }
                        if (table3.Rows.Count > 0)
                        {
                            str = str + "]";
                        }
                    }
                    builder.AppendLine(string.Concat(new object[] { "<td style=\"height: 32px;text-align:left\"><a href=\"order_info.html?orderNo=", row["orderNo"], "\">", str, "</a></td>" }));
                    builder.AppendLine("<td style=\"height: 32px\">" + Convert.ToDateTime(row["createTime"]).ToString("yyyy/MM/dd") + "</td>");
                    builder.AppendLine("<td style=\"height: 32px\">" + string.Format("{0:C}", row["orderTotal"]) + "</td>");
                    string str2 = "";
                    string str3 = "";
                    switch (Convert.ToInt32(row["payStatus"]))
                    {
                        case 0:
                            str2 = "[未支付]";
                            break;

                        case 1:
                            str2 = "[已支付]";
                            break;
                    }
                    switch (Convert.ToInt32(row["deliveryStatus"]))
                    {
                        case 0:
                            str3 = "[未发货]";
                            break;

                        case 1:
                            str3 = "[已发货]<br /><a href=\"javascript:return false;\" onclick=\"aConfirm('" + row["orderNo"] + "');\">[确认收货]</a>";
                            break;

                        case 2:
                            str3 = "[已收货]<br /><a href=\"/cn/goods_comment.html?orderNo=" + row["orderNo"] + "\">商品评价</a>";
                            break;
                    }
                    builder.AppendLine("<td style=\"height: 32px\">" + str2 + "<br />" + str3 + "</td>");
                    builder.AppendLine("</tr>");
                }
                return builder;
            }
            builder.AppendLine("<tr>");
            builder.AppendLine("<td colspan=\"5\" style=\"text-align: center; color: #ff0000;\">没有找到任何记录</td>");
            builder.AppendLine("</tr>");
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (base.LoginUserMember == null)
        {
            base.Response.Redirect("/cn/web_login.html?ru=" + HttpContext.Current.Request.Url.PathAndQuery.Replace("aspx", "html"));
        }
    }

}